#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

void char_overflow(void)
{
	char a[1000];
	int i;
	for (i = 0; i < 1000; i++) {
		a[i] = -1 -i;	
		if (0 == a[i]) { break; }
	}
	printf("strlen(a) = %zd i = %d\n", strlen(a), i);
	printf("%d\n", (char)(127 + 1));
}

void unsigned_overflow(void)
{
	unsigned i;

	printf("%u\n", ((int)-20 + (unsigned int)10)); /* int->unsigned int */
	printf("%u\n", -20);

	for (i = 9; i >= 0; i--) {
		printf("i = %u\n", i);
		sleep(1);
	}
}

int main(int argc, char*argv[])
{
	//char_overflow();
	unsigned_overflow();
	return 0;
}
